package bpmn.diagram.providers;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.common.core.service.AbstractProvider;
import org.eclipse.gmf.runtime.common.core.service.IOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.GetParserOperation;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
import org.eclipse.gmf.runtime.common.ui.services.parser.IParserProvider;
import org.eclipse.gmf.runtime.common.ui.services.parser.ParserService;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
import org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter;
import org.eclipse.gmf.runtime.notation.View;

import bpmn.BpmnPackage;
import bpmn.diagram.edit.parts.DataObjectNameEditPart;
import bpmn.diagram.edit.parts.LaneName2EditPart;
import bpmn.diagram.edit.parts.LaneNameEditPart;
import bpmn.diagram.edit.parts.ProcessNameEditPart;
import bpmn.diagram.edit.parts.TaskName2EditPart;
import bpmn.diagram.edit.parts.TaskName3EditPart;
import bpmn.diagram.edit.parts.TaskName4EditPart;
import bpmn.diagram.edit.parts.TaskName5EditPart;
import bpmn.diagram.edit.parts.TaskName6EditPart;
import bpmn.diagram.edit.parts.TaskName7EditPart;
import bpmn.diagram.edit.parts.TaskName8EditPart;
import bpmn.diagram.edit.parts.TaskName9EditPart;
import bpmn.diagram.edit.parts.TaskNameEditPart;
import bpmn.diagram.parsers.MessageFormatParser;
import bpmn.diagram.part.Bpmn_1_1VisualIDRegistry;

/**
 * @generated
 */
public class Bpmn_1_1ParserProvider extends AbstractProvider implements
		IParserProvider {

	/**
	 * @generated
	 */
	private IParser processName_5012Parser;

	/**
	 * @generated
	 */
	private IParser getProcessName_5012Parser() {
		if (processName_5012Parser == null) {
			EAttribute[] features = new EAttribute[] { BpmnPackage.eINSTANCE
					.getProcess_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			processName_5012Parser = parser;
		}
		return processName_5012Parser;
	}

	/**
	 * @generated
	 */
	private IParser taskName_5003Parser;

	/**
	 * @generated
	 */
	private IParser getTaskName_5003Parser() {
		if (taskName_5003Parser == null) {
			EAttribute[] features = new EAttribute[] { BpmnPackage.eINSTANCE
					.getFlowObject_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			taskName_5003Parser = parser;
		}
		return taskName_5003Parser;
	}

	/**
	 * @generated
	 */
	private IParser taskName_5011Parser;

	/**
	 * @generated
	 */
	private IParser getTaskName_5011Parser() {
		if (taskName_5011Parser == null) {
			EAttribute[] features = new EAttribute[] { BpmnPackage.eINSTANCE
					.getFlowObject_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			taskName_5011Parser = parser;
		}
		return taskName_5011Parser;
	}

	/**
	 * @generated
	 */
	private IParser taskName_5013Parser;

	/**
	 * @generated
	 */
	private IParser getTaskName_5013Parser() {
		if (taskName_5013Parser == null) {
			EAttribute[] features = new EAttribute[] { BpmnPackage.eINSTANCE
					.getFlowObject_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			taskName_5013Parser = parser;
		}
		return taskName_5013Parser;
	}

	/**
	 * @generated
	 */
	private IParser taskName_5014Parser;

	/**
	 * @generated
	 */
	private IParser getTaskName_5014Parser() {
		if (taskName_5014Parser == null) {
			EAttribute[] features = new EAttribute[] { BpmnPackage.eINSTANCE
					.getFlowObject_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			taskName_5014Parser = parser;
		}
		return taskName_5014Parser;
	}

	/**
	 * @generated
	 */
	private IParser taskName_5015Parser;

	/**
	 * @generated
	 */
	private IParser getTaskName_5015Parser() {
		if (taskName_5015Parser == null) {
			EAttribute[] features = new EAttribute[] { BpmnPackage.eINSTANCE
					.getFlowObject_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			taskName_5015Parser = parser;
		}
		return taskName_5015Parser;
	}

	/**
	 * @generated
	 */
	private IParser taskName_5016Parser;

	/**
	 * @generated
	 */
	private IParser getTaskName_5016Parser() {
		if (taskName_5016Parser == null) {
			EAttribute[] features = new EAttribute[] { BpmnPackage.eINSTANCE
					.getFlowObject_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			taskName_5016Parser = parser;
		}
		return taskName_5016Parser;
	}

	/**
	 * @generated
	 */
	private IParser taskName_5017Parser;

	/**
	 * @generated
	 */
	private IParser getTaskName_5017Parser() {
		if (taskName_5017Parser == null) {
			EAttribute[] features = new EAttribute[] { BpmnPackage.eINSTANCE
					.getFlowObject_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			taskName_5017Parser = parser;
		}
		return taskName_5017Parser;
	}

	/**
	 * @generated
	 */
	private IParser taskName_5018Parser;

	/**
	 * @generated
	 */
	private IParser getTaskName_5018Parser() {
		if (taskName_5018Parser == null) {
			EAttribute[] features = new EAttribute[] { BpmnPackage.eINSTANCE
					.getFlowObject_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			taskName_5018Parser = parser;
		}
		return taskName_5018Parser;
	}

	/**
	 * @generated
	 */
	private IParser taskName_5019Parser;

	/**
	 * @generated
	 */
	private IParser getTaskName_5019Parser() {
		if (taskName_5019Parser == null) {
			EAttribute[] features = new EAttribute[] { BpmnPackage.eINSTANCE
					.getFlowObject_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			taskName_5019Parser = parser;
		}
		return taskName_5019Parser;
	}

	/**
	 * @generated
	 */
	private IParser dataObjectName_5007Parser;

	/**
	 * @generated
	 */
	private IParser getDataObjectName_5007Parser() {
		if (dataObjectName_5007Parser == null) {
			EAttribute[] features = new EAttribute[] { BpmnPackage.eINSTANCE
					.getDataObject_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			dataObjectName_5007Parser = parser;
		}
		return dataObjectName_5007Parser;
	}

	/**
	 * @generated
	 */
	private IParser laneName_5009Parser;

	/**
	 * @generated
	 */
	private IParser getLaneName_5009Parser() {
		if (laneName_5009Parser == null) {
			EAttribute[] features = new EAttribute[] { BpmnPackage.eINSTANCE
					.getSwimlane_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			laneName_5009Parser = parser;
		}
		return laneName_5009Parser;
	}

	/**
	 * @generated
	 */
	private IParser laneName_5008Parser;

	/**
	 * @generated
	 */
	private IParser getLaneName_5008Parser() {
		if (laneName_5008Parser == null) {
			EAttribute[] features = new EAttribute[] { BpmnPackage.eINSTANCE
					.getSwimlane_Name() };
			MessageFormatParser parser = new MessageFormatParser(features);
			laneName_5008Parser = parser;
		}
		return laneName_5008Parser;
	}

	/**
	 * @generated
	 */
	protected IParser getParser(int visualID) {
		switch (visualID) {
		case ProcessNameEditPart.VISUAL_ID:
			return getProcessName_5012Parser();
		case TaskNameEditPart.VISUAL_ID:
			return getTaskName_5003Parser();
		case TaskName2EditPart.VISUAL_ID:
			return getTaskName_5011Parser();
		case TaskName3EditPart.VISUAL_ID:
			return getTaskName_5013Parser();
		case TaskName4EditPart.VISUAL_ID:
			return getTaskName_5014Parser();
		case TaskName5EditPart.VISUAL_ID:
			return getTaskName_5015Parser();
		case TaskName6EditPart.VISUAL_ID:
			return getTaskName_5016Parser();
		case TaskName7EditPart.VISUAL_ID:
			return getTaskName_5017Parser();
		case TaskName8EditPart.VISUAL_ID:
			return getTaskName_5018Parser();
		case TaskName9EditPart.VISUAL_ID:
			return getTaskName_5019Parser();
		case DataObjectNameEditPart.VISUAL_ID:
			return getDataObjectName_5007Parser();
		case LaneNameEditPart.VISUAL_ID:
			return getLaneName_5009Parser();
		case LaneName2EditPart.VISUAL_ID:
			return getLaneName_5008Parser();
		}
		return null;
	}

	/**
	 * Utility method that consults ParserService
	 * @generated
	 */
	public static IParser getParser(IElementType type, EObject object,
			String parserHint) {
		return ParserService.getInstance().getParser(
				new HintAdapter(type, object, parserHint));
	}

	/**
	 * @generated
	 */
	public IParser getParser(IAdaptable hint) {
		String vid = (String) hint.getAdapter(String.class);
		if (vid != null) {
			return getParser(Bpmn_1_1VisualIDRegistry.getVisualID(vid));
		}
		View view = (View) hint.getAdapter(View.class);
		if (view != null) {
			return getParser(Bpmn_1_1VisualIDRegistry.getVisualID(view));
		}
		return null;
	}

	/**
	 * @generated
	 */
	public boolean provides(IOperation operation) {
		if (operation instanceof GetParserOperation) {
			IAdaptable hint = ((GetParserOperation) operation).getHint();
			if (Bpmn_1_1ElementTypes.getElement(hint) == null) {
				return false;
			}
			return getParser(hint) != null;
		}
		return false;
	}

	/**
	 * @generated
	 */
	private static class HintAdapter extends ParserHintAdapter {

		/**
		 * @generated
		 */
		private final IElementType elementType;

		/**
		 * @generated
		 */
		public HintAdapter(IElementType type, EObject object, String parserHint) {
			super(object, parserHint);
			assert type != null;
			elementType = type;
		}

		/**
		 * @generated
		 */
		public Object getAdapter(Class adapter) {
			if (IElementType.class.equals(adapter)) {
				return elementType;
			}
			return super.getAdapter(adapter);
		}
	}

}
